<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Table</title>
		<link rel="stylesheet" href="#(base)/static/admin/plugins/layui/css/layui.css" media="all" />
		<link rel="stylesheet" href="#(base)/static/admin/css/global.css" media="all">
		<link rel="stylesheet" href="#(base)/static/admin/plugins/font-awesome/css/font-awesome.min.css">
		<link rel="stylesheet" href="#(base)/static/admin/css/table.css" />
		<script type="text/javascript" src="#(base)/static/admin/js/jquery.js"></script>
		<script type="text/javascript" src="#(base)/static/admin/js/list.js"></script>
	</head>

	<body>
		<div class="admin-main">

			<blockquote class="layui-elem-quote">
				<a href="#(base)/admin/ad/add" class="layui-btn layui-btn-small">
					<i class="layui-icon">&#xe608;</i> 新增
				</a>
			</blockquote>
			<form id="listForm" action="#(base)/admin/ad/list" method="post">
			<fieldset class="layui-elem-field">
				<legend>数据列表</legend>
				<div class="layui-field-box">
					<table class="site-table table-hover">
						#include("/common/table_head.html")
						<tbody>
							#for(element : list)
								<tr>
								#include("/common/table_body.html")
									<td>
										<a href="#(base)/admin/ad/edit/#(element.attributeValue("id"))" class="layui-btn layui-btn-mini">修改</a>
										<a href="#(base)/admin/ad/delete/#(element.attributeValue("id"))" class="layui-btn layui-btn-mini">删除</a>
									</td>
								</tr>
							#end
						</tbody>
					</table>
				</div>
			</fieldset>
			</form>	
		</div>
		<script type="text/javascript" src="#(base)/static/admin/plugins/layui/layui.js"></script>
		<script>
			layui.config({
				base: '#(base)/static/admin/plugins/layui/modules/'
			});

			layui.use(['icheck', 'laypage'], function() {
				$('input').iCheck({
					checkboxClass: 'icheckbox_flat-green'
				});

				
				$('.site-table tbody tr').on('click', function(event) {
					var $this = $(this);
					var $input = $this.children('td').eq(0).find('input');
					$input.on('ifChecked', function(e) {
						$this.css('background-color', '#EEEEEE');
					});
					$input.on('ifUnchecked', function(e) {
						$this.removeAttr('style');
					});
					$input.iCheck('toggle');
				}).find('input').each(function(){
					var $this = $(this);
					$this.on('ifChecked', function(e) {
						$this.parents('tr').css('background-color', '#EEEEEE');
					});
					$this.on('ifUnchecked', function(e) {
						$this.parents('tr').removeAttr('style');
					});
				});
				$('#selected-all').on('ifChanged', function(event) {
					var $input = $('.site-table tbody tr td').find('input');
					$input.iCheck(event.currentTarget.checked ? 'check' : 'uncheck');
				});
			});
		</script>
	</body>

</html>